package com.alibaba.citrus.cr.common.enums.ordercenter;

import lombok.Getter;

import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

@Getter
public enum SalesOrderStatusEnum {

    CANCELLED(-1, "已取消"),
    BEFORE_SUBMIT(1, "待提交"),
    BEFORE_DELIVERY(2, "待交货"),
    PARTIAL_DELIVER(3, "部分交货"),
    COMPLETED(4, "已完成"),
    SHIPPED(5, "已发货"),
    STAY_PUSH(6, "待推送"),
    PUSHING(7, "已推送"),
    PARTIAL_HANDLE(11, "部分处理"),
    WAIT_HANDLE(12, "待处理"),
    WAIT_RECEIVING(13, "待收货"),
    PART_RECEIVING(14, "部分收货");

    private final Integer code;
    private final String desc;

    SalesOrderStatusEnum(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static SalesOrderStatusEnum of(Integer code) {
        return Arrays.stream(SalesOrderStatusEnum.values()).filter(source -> Objects.equals(code, source.getCode())).findFirst().orElse(null);
    }

    public static List<Integer> codes() {
        return Arrays.stream(SalesOrderStatusEnum.values()).map(SalesOrderStatusEnum::getCode).collect(Collectors.toList());
    }
}
